var access_token="ae9111cd-fbd1-489c-8a63-588010d231b7";
var term_mac="76006DF26D1D4B109EA7E458A95A4FE8";
var term_id="T0000011";

$(document).ready(function(){
	var biz_type = $("#biz_type",parent.document).val();
	var province = $("#province",parent.document).val();
	
	term_id = window.CallCSharpMethod("getWebBrowerVariables", "term_id");
	access_token = window.CallCSharpMethod("getWebBrowerVariables", "access_token");
	term_mac = window.CallCSharpMethod("getWebBrowerVariables", "term_mac");
	
	var biz_info={
		biz_type:biz_type,
		province:province,
		access_token:access_token,		//"eca620b0-f3c0-42fa-8569-1adfcd79ea7c",
		term_mac:term_mac,				//"76006DF26D1D4B109EA7E458A95A4FE8",
		term_id:term_id						//"T0000011"
	};
	var jsonStr = JSON.stringify(biz_info);
	$.ajax({
		type:"post",
		url:"../ebpp/getCity.do",
		data:{searchCondition:jsonStr},
		async:false,
		cache:false,
		dataType:"json",
		success:function(json){
			showCityData(json);
		}
	});
});

function showCityData(json){
	
	if(json!=null && json.success == "true"){
		
		var cities = json.citys;
		
		for(var i=0;i<cities.length;i++){
	
			var cityName = "city_" + i;
			var html = '<div id="sub_x">' 
						+ '<span id="' + cityName + '">'
				 		+ '</span>' 
				 	 + '</div>';
	    	$("#Scro").append(html);
	    	
			var strName = cities[i];
			
			var spanName = "city_" + i;
			html_city = '<span href = "" onclick="city_click(\''+ strName +'\')"; ">'
			          + '<div class="sub_city">'
			             +'<label>'+ strName +'</label>'
			          + '</div>'
			          + '</span>';
			$("span#" + spanName).append(html_city);
		}
	}
}



function sel_city_click(city){
	$(strInputElement).attr("value", city);
	$("#city_choose_back").click();
}

function city_click(city){
	$("#txt_company",parent.document).val("");
	parent.sel_city_click(city);
}